package com.settlement.system.common.util;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

public class ReflectionUtils {
    /**
     * description 获取实体的所有字段，和对应注解值
     *
     * @param object 实体
     */
    public static Map<String, String> getFieldAnnotation(Object object) {
        Field[] fields = object.getClass().getDeclaredFields();
        Map<String, String> resultMap = new HashMap<>();
        for (Field field : fields) {
            try {
                field.setAccessible(true);
                String value = field.get(object).toString();
                resultMap.put(field.getName(), value);
            } catch (Exception e) {
//                e.printStackTrace();
            }
        }
        return resultMap;
    }
}
